import{createRouter,createWebHashHistory, RouterView} from 'vue-router'
import admin from './admin'
import { h } from 'vue'
import component from 'element-plus/es/components/tree-select/src/tree-select-option.mjs'

const router=createRouter({
    history:createWebHashHistory(),
    routes:[
      { path: '/', redirect:'/home' },
      //登录
      {
        path:'/login',
        component:()=>import('@/layout/login.vue'),
      },
      {
        path:'/register',
        component:()=>import('@/layout/register.vue'),
      },
      {
        path:'/updatePassword',
        component:()=>import('@/layout/updatePassword.vue'),
      },
      //首页
      {
        path:'/home',
        component:()=>import('@/layout/layout.vue'),
        // meta:{show:true},
        redirect:'/home',
        children:[
          {
            path:'',
            meta:{
              title:'首页',
            },
            component:()=>import('@/views/home/index.vue')
          },
          {
            path:'fabu',
            meta:{
              title:'发布',
            },
            component:()=>import('@/views/home/fabu.vue')
          },
        ]
      },
      // 戏曲
      {
        path:'/video',
        component:()=>import('@/layout/layout.vue'),
        // meta:{show:true},
        redirect:'/video',
        children:[
          {
            path:'',
            meta:{
              title:'戏曲',
            },
            component:()=>import('@/views/video/index.vue')
          },
          {
            path:'fabu',
            meta:{
              title:'发布',
            },
            component:()=>import('@/views/video/fabu.vue')
          },
          {
            path:'videoInfo',
            meta:{
              title:'戏曲详情',
            },
            component:()=>import('@/views/video/videoInfo.vue')
          },
        ]
      },
      // 活动
      {
        path:'/activity',
        component:()=>import('@/layout/layout.vue'),
        // meta:{show:true},
        redirect:'/activity',
        children:[
          {
            path:'',
            meta:{
              title:'活动',
            },
            component:()=>import('@/views/activity/index.vue')
          },
          {
            path:'fabu',
            meta:{
              title:'发布',
            },
            component:()=>import('@/views/activity/fabu.vue')
          },
        ]
      },
      // ai
      {
        path:'/aiChat',
        component:()=>import('@/layout/layout.vue'),
        // meta:{show:true},
        redirect:'/aiChat',
        children:[
          {
            path:'',
            meta:{
              title:'ai聊天',
            },
            component:()=>import('@/views/ai/index.vue')
          },
        ]
      },
      //主页
      {
        path:'/my',
        component:()=>import('@/layout/layout.vue'),
        // meta:{show:true},
        redirect:'/my',
        children:[
          {
            path:'',
            meta:{
              title:'主页',
            },
            component:()=>import('@/views/my/index.vue')
          },
        ]
      },
      // {
      //   path:'/test',
      //   component:()=>import('@/views/modules/test.vue')
      // },
      // 管理端
      ...admin
    ]
})

// 函数用于递归遍历路由记录
// function printChildrenPaths(routes) {
//   routes.forEach(route => {
//     if (route.children && route.children.length == 1) {
//       console.log(`Parent Path: ${route.path}`);
//       printChildrenPaths(route.children); // 递归调用
//     } else {
//       console.log(`Pathdasd: ${route.path}`);
//     }
//   });
// }

// // 打印子路由路径
// printChildrenPaths(router.getRoutes());


export default router